package com.abstractgames;

import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;

public class Game implements ApplicationListener{
	
//	public static int WIDTH = DesktopStarter.WIDTH;
//	public static int HEIGHT = DesktopStarter.HEIGHT;

	
	public static boolean running = false;
	
	public static Input input;
	public static Screen screen;
	public static Physics physics;
	public static Audio audio;
	
//	private float textWidth;
//	private float textHeight;
	
	private float timecounter = 0;
	private float period = 15.0f;
	

	
	@Override
	public void create() {
		input = new Input();
		Gdx.input.setInputProcessor(input);
		
		screen = new Screen();
		physics = new Physics();		
		audio = new Audio();
		
		//font = new BitmapFont();
		//textWidth = font.getBounds(textToDisplay).width;
		//textHeight = font.getBounds(textToDisplay).height;
		
		running = true;
		Gdx.app.log("Game","create()");		
	}

	@Override
	public void render() {
		
		timecounter += Gdx.graphics.getDeltaTime();
		while (timecounter > 1.0f / period) {
			if (running) {
				physics.tick();
			}
			timecounter -= 1.0f / period;
		}
		screen.tick();
		
//		if(running&&!Mouse.isInsideWindow()) {
//			running = false;
//			Gdx.app.log("Game","pause()");
//			}
//		
//		if ((!running&&Mouse.isInsideWindow())){
//			running = true;
//			Gdx.app.log("Game","resume()");
//		}
				
	}
	
	@Override
	public void resize(int arg0, int arg1) {
		Gdx.app.log("Game","resize()");
	}
	@Override
	public void dispose() {
		Gdx.app.log("Game","dispose()");
		
	}
	@Override
	public void pause() {
		Gdx.app.log("Game","pausefinal()");
	}
	@Override
	public void resume() {
		Gdx.app.log("Game","resumefinal()");
	}

}

